#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include<QTcpServer>
#include<QTcpSocket>
#include<QMetaEnum>
#include<list>

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

/**
 * @brief 用QTcpServer和QTcpSocket，实现tcp通信服务端
 */
class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

private slots:
    void on_btnStart_clicked();
    void  onNewConnection();
    void  onReadyRead();
    void  onDisconnected();
    void on_btnSend_clicked();

private:
    Ui::Widget *ui;
    QTcpServer m_tcpServer;
    bool m_start = false;

     std::list<QTcpSocket *> m_clientList; ///< 所有客户端
};
#endif // WIDGET_H
